var common = {
    //成功弹出
    success: function (mess, url) {
        layer.msg(mess, {icon: 6,time:2000}, function (index) {
            layer.close(index);
            window.location.href = url;
        });
    },
    //错误弹出
    error: function (message) {
        layer.msg(message, {icon: 5,time:1000}, function (index) {
            layer.close(index);
        });
    },
    del: function (id,url,gotoUrl) {
        layer.confirm('确认删除这货吗？', {
            btn: ['删除','取消'] //按钮
        }, function(){
            $.post(url,{id:id},function(data){
                if(data.state > 0){
                    sxshop.error(data.msg);
                }else{
                    sxshop.success(data.msg,gotoUrl);
                }
            });
        });
    },
    //改变状态
    state: function (id,url,objectState) {
        $.post(url,{id:id}, function (data) {
            if(data.state > 0){
                sxshop.error(data.msg);
                return false;
            }else{
                if(data.data == 1){
                    objectState.removeClass('label-danger').addClass('label-primary').html('正常');
                }else{
                    objectState.removeClass('label-primary').addClass('label-danger').html('禁用');
                }
            }
        });
    },

    states: function (id,url,objectState) {
        $.post(url,{id:id}, function (data) {
            if(data.state > 0){
                sxshop.error(data.msg);
                return false;
            }else{
                if(data.data == 1){
                    objectState.removeClass('label-danger').addClass('label-primary').html('推荐');
                }else{
                    objectState.removeClass('label-primary').addClass('label-danger').html('热门');
                }
            }
        });
    }

}